#!/bin/bash
#!syntaxe de la commande: ./comp.sh
if test -e "resultats.txt"
then
	rm resultats.txt
fi


echo "/***********************************************************************/">> resultats.txt
echo "     *                                                       	*">> resultats.txt
echo "     * 	COMPARAISON DES TECHNIQUES DE DETECTION DE CONTOURS	*">> resultats.txt
echo "     *								*">> resultats.txt
echo "/***********************************************************************/">> resultats.txt
echo "	">> resultats.txt

ls "./gradiant"| grep "pgm" >aux
L=1
IFS=$'\n'
for ligne in $(cat aux)
do

#!Image du gradiant

gradiant=$ligne


#!Image de reférence

dirpah="./gradiant"
cd $dirpah 2> /dev/null
prefix=$( ls $gradiant |cut -d '-' -f 1)
type=$( ls $gradiant |cut -d '-' -f 2)
seuil=$( ls $gradiant |cut -d '-' -f 3)
reference=$( ls "../reference" | grep $prefix)


#!Affichage des resultats
echo "	">> ../resultats.txt
echo $L".	Type de Detection :" $type"	Seuil    :" $seuil>> ../resultats.txt
echo "	Image Gradiant    :" $ligne>> ../resultats.txt
echo "	Image Reférence   :" $reference>> ../resultats.txt

#!Comparaison des images
../contours -comp "../reference/"$reference  "../gradiant/"$gradiant >> ../resultats.txt

echo "	">> ../resultats.txt
echo "// *************************************************//">> ../resultats.txt

L=$(expr $L + 1)
done
rm ../aux
exit 0
